home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir34 / bkup10.zip / BKUP10.BTM < prev    next >
Text File  |  1994-05-18  |  23KB  |  824 lines

  1. :: ------------------------------------------------------------------
  2. :  BKUP.BTM, version 10, May 5, 1994
  3. :  Read BKUP.DOC for detailed description, or type BKUP H
  4. :  Call BKUP.INI to modify defaults.
  5. :: ------------------------------------------------------------------
  6. :  This is the main BKUP batch. See BKUP.LST for a full list.
  7. :: ------------------------------------------------------------------
  8. :  Itamar Even-Zohar (itamarez@plato.tau.ac.il)
  9. :: ------------------------------------------------------------------
  10.  
  11. :2help  :: (displays HELP if you type H, ?, or /?, or I)
  12. iff %@index[%1,h] eq 0 .or. %@index[%1,?] ge 0 .or. %@index[%1,i] eq 0 then
  13. call bk-hlp.btm %1
  14. endiff
  15.  
  16. iff %_4ver lt 5 then
  17. cls
  18. beep
  19. screen 2 0
  20. text
  21.     This version of BKUP does not support 4DOS version 4.x.
  22.     Please use previous versions.
  23. endtext
  24. cancel
  25. endiff
  26.  
  27. setlocal
  28. set args=%1&
  29.  
  30. gosub bk-prams
  31. :: (bk-prams.btm checks and sets various parameters)
  32.  
  33. :ex_choice
  34. :: (if x or -x specified, the extraction part will work)
  35. iff %@index[%1,x] ge 0 .and. %@index[%1,x] lt 2 then
  36.   goto extract_f
  37. endiff
  38.  
  39. gosub check_args
  40. :: (defining drives for opeations if not defined elsewhere)
  41.  
  42. :check_compu
  43. :: (checking computer's "name")
  44. if "%compuname"=="" gosub compuname
  45. ::goto set_params
  46.  
  47. :get_date  :: (separates typed date from -s or s ["since"] in date)
  48. iff %@index[%1,/s] ge 0 .or. %@index[%1,-s] ge 0 then
  49.    set date0=%@substr[%1,2]
  50.    goto set_defaults
  51. elseiff %@index[%1,s] eq 0 then
  52.    set date0=%@substr[%1,1]
  53.    goto set_defaults
  54. else
  55.    goto compu_date
  56. endiff
  57.  
  58. :compu_date
  59. set days=%@date[%_date]
  60. :      This is today'y date in full numbers since 1-1-1980
  61. set date0=%@makedate[%@eval[%days-%1]]
  62. :      This is the actual date desired for the archive file.
  63. :      If no number of days indicated by user, you get today's
  64. :      date again.
  65. if %@index[%date0,0] eq 0 set date0=%@substr[%date0,1]
  66. :      If a zero (0) is contained on the first position (01, etc.),
  67. :      it will be removed.
  68.  
  69. :set_defaults
  70. :: (setting: temporary archive name, final archive name;
  71. :: removing: old temporary archive; verifying: colors for message)
  72. ::
  73. set rsp=%temp%upd.rsp
  74. set zipfn=%temp%upd.%zip_ext
  75. set tmpf=%@unique[%temp]
  76. if exist %zipfn del /q %zipfn
  77. :: (This is just a precaution; this file is moved anyway, if batch
  78. :: terminates in a normal way.)
  79. if .%colordir==. set colordir=dirs:bright white;zip uc:black on white;
  80.  
  81. :re-use?  :: (Use again the updates file or create a new one?)
  82. cls
  83. if exist %rsp goto ask
  84. goto accumulate
  85.  
  86. :ask
  87. :: (use extant list of updates or create a new one?)
  88. echo.
  89. gosub legenda
  90. screen 2 0
  91. inkey /K"YNVESQ" Use extant list file? (created %@filedate[%rsp], at %@filetime[%rsp])? [time now: %_time]n (List File is: %@upper[%rsp])nnType Y/N, V(iew), S(creen), E(dit), or Q(uit) %%rep
  92.     iff %rep == Q then cls^screen 2 0^set ech=echo Stopped by user^ goto end
  93. elseiff %rep == Y then goto backup
  94. elseiff %rep == V then *list %rsp^cls^goto ask
  95. elseiff %rep == E then %edt %rsp^goto backup
  96. elseiff %rep == S then echo. >%tmpf^cls^set num=0^goto edit
  97. elseiff %rep == N goto accumulate
  98. endiff
  99.  
  100. :accumulate
  101. cls
  102.   iff %_monitor == mono then
  103. screen 4 5 [ making a list of all new files created since %date0 ]
  104. screen 3 5 Working ...
  105.   else
  106. scrput 4 5 gre on whi [ making a list of all new files created since %date0 ]
  107. scrput 3 5 blu on whi  Working ...
  108.   endiff
  109.  
  110. :make_list
  111. :: (Create the updates file with 4DOS internal dir /d command
  112. :: [valid only from version 5.x])
  113. cdd %search_drive:\
  114. dir /bsa:a /[d%date0] >%rsp
  115.  
  116. :check_list
  117.   iff %@lines[%rsp] lt 0 then
  118.   set ech=scrput 3 17 bri whi on bla No files were found for/since %date0!
  119.   del /q %rsp
  120.   goto end
  121.   endiff
  122. scrput 3 17 bri whi on bla List created as %@upper[%rsp]
  123.  
  124. :edit?
  125. screen 6 5 Select an option (press first letter):
  126. screen 7 5
  127. text
  128.  
  129.    Screen  select files on screen (one file after another)
  130.            (this option allows viewing and deleting)
  131.    Edit    edit results file via editor
  132.    View    view results before making any decision
  133.    Go      go to immediate archiving (no selection)
  134.    Quit    stop now (results file will remain intact)
  135. endtext
  136. screen 16 3
  137. inkey /K"SEQGV[ESC][Enter]" Your choice?  %%rep
  138. iff %rep == G then goto backup
  139.   elseiff %rep == S .or. %rep == @28 then
  140.     echo. >%tmpf
  141.     cls
  142.     set num=0
  143.     goto edit
  144.   elseiff %rep == E then
  145.     %edt %rsp
  146.     goto backup
  147.   elseiff %rep == V then
  148.     *list %rsp
  149.     cls^goto edit?
  150.   elseiff %rep == Q .or. %rep == %@char[27] then
  151.     set ech=echo Stopped by user^goto end
  152. endiff
  153.  
  154. :edit
  155. rem   This procedure displays all the files saved today, one by one,
  156. :     allowing you to (a) select only those you wish to back up, or
  157. :     (b) delete, or (c) view a file before making a decision, or
  158. :     (d) view the list of selections, or (e) stop selecting and go
  159. :     to immediate archiving, or (f) quit.
  160. :
  161. iff %@eval[%num] gt %@lines[%rsp] then
  162.   move /q %tmpf %rsp
  163.   goto backup
  164.   endiff
  165. set fn=%@line[%rsp,%num]
  166. if .%fn==. (set num=%@eval[%num+1]^goto edit)
  167. scrput 0 0 black on white  Accept=A/enter Omit=O/Esc D=Delete V=View G=Begin archiving L=View list Q=Quit 
  168. echo.
  169.   iff %_row lt 2 then
  170.   screen 2 0
  171.   endiff
  172. echo ==`>` %fn
  173.   iff %_row ge %@eval[%_rows -1] then
  174.   cls
  175.   goto edit^endiff
  176. inkey /K"YNAODVGLQ[ESC][Enter]" A(ccept)? O(mit)? D(elete)? V(iew)? G(o)? (L)ist Q(uit)?  %%rep
  177. iff %rep == %@char[27] .or. %rep == O .or. %rep == N then
  178.      set num=%@eval[%num +1]
  179.      goto edit
  180.      :REM: see label ':note' below
  181. elseiff %rep == A .or. %rep == @28 .or. %rep == Y then
  182.      echo %fn >>%tmpf
  183.      set num=%@eval[%num +1]
  184.      goto edit
  185. elseiff %rep == D then
  186.      del /q %fn
  187.      echo ==`>` %fn deleted^echo.
  188.      set num=%@eval[%num +1]
  189.      goto edit
  190. elseiff %rep == V then
  191.      *list %fn
  192.      echo.^goto edit
  193. elseiff %rep == G then
  194.      set num=%@eval[%@lines[%rsp]+1]
  195.      goto edit
  196. elseiff %rep == L then
  197.      *list %tmpf
  198.      echo.^goto edit
  199. elseiff %rep == Q then set ech=echo Stopped by user^goto end
  200. endiff
  201.  
  202. :backup
  203. cdd %temp
  204. rem  (Checking if there are any file at all to back up)
  205.   gosub void
  206.   
  207. :update
  208. rem  (If zip archive exists on target diskette, update it)
  209. cls^echo.^echo.
  210. gosub check_drive
  211. iff exist %dr:\%date0.%zip_ext then
  212. set fn=%dr:\%date0.%zip_ext
  213. set state=old
  214. :: (The following 2 lines are just to remind the reader of parameters
  215. :: set up in BK-PRAMS.BTM.)
  216. :: if "%zip_pgm"=="zip"   set pkz=zip -uk -b%temp -9
  217. :: if "%zip_pgm"=="pkzip" set pkz=pkzip -b%temp -P -u -ex
  218. cls
  219. screen 2 0
  220. gosub void
  221. if "%zip_pgm"=="zip"   set pkz=%pkz %dr:\%date0.%zip_ext -@ `<`%rsp %exclude `>&>`nul
  222. if "%zip_pgm"=="pkzip" set pkz=%pkz %exclude %dr:\%date0.%zip_ext @%rsp
  223. if "%zip_pgm"=="uc"    set pkz=%pkz %dr:\%date0.%zip_ext @%rsp %exclude
  224.  
  225. :: (execute compression now)
  226.  
  227. %pkz
  228. gosub success
  229. goto end
  230. endiff
  231.  
  232. :create_zip
  233. cls
  234. screen 2 0
  235. gosub void
  236. if "%zip_pgm"=="zip"   set pkz=%pkz %zipfn -@ `<`%rsp %exclude `>&>`nul
  237. if "%zip_pgm"=="pkzip" set pkz=%pkz %exclude %zipfn @%rsp
  238. if "%zip_pgm"=="uc"    set pkz=%pkz %zipfn @%rsp %exclude
  239. ::
  240. :: (execute compression now)
  241. %pkz
  242. gosub success
  243.  
  244. :check_room
  245. rem  (Checking if there is room for backup file on target)
  246. iff %@diskfree[%dr:,b] lt %@filesize[%zipfn,b] then
  247. set ech=Echo No room on drive %@upper[%dr:]! %zipfn was left on %temp
  248.   goto end
  249.   else
  250. set ech=echo Backup archive created on drive %@upper[%dr:]
  251. endiff
  252.  
  253. :move_zip
  254. gosub check_drive
  255. move /q %zipfn %dr:\%date0.%zip_ext
  256. set brand=upd
  257. set fn=%dr:\%date0.%zip_ext
  258. gosub brand
  259.  
  260. :end
  261. if exist %tmpf del /q %tmpf
  262. if exist %excls_file del /q %excls_file
  263. echo.
  264. %ech
  265. echo.
  266.   iff %@index[%ech,Stopped] ge 0 then goto interrupt
  267.   elseiff %@index[%ech,No new] ge 0 then goto interrupt
  268.   elseiff %@index[%ech,No files we] ge 0 then goto interrupt
  269.   elseiff %@index[%ech,could not be] ge 0 then goto interrupt
  270.   endiff
  271. if exist %dr:\%date0.%zip_ext dir /klm %dr:\%date0.%zip_ext
  272. echo.
  273. :interrupt
  274. endlocal
  275. quit
  276.  
  277. ::*===========End of archiving part===================*::
  278.  
  279. ::*===========Begin extraction part===================*::
  280. :extract_f
  281. :: Since version 8, a menu will pop up even if the archive diskette
  282. :: contains only one archive (zip) file. This will allow canceling
  283. :: extraction (by ESC). If you prefer the older procedure, you will
  284. :: have to add one more preliminary step before "select...".
  285.  
  286. :set_extr_drive
  287. gosub check_args_x
  288.  
  289. cdd %archive_drive:\
  290. cdd %toupdate_drive:\
  291. if not exist %archive_drive:*-?*-??.%zip_ext goto failure
  292.  
  293. :extract
  294. set fnt=%@unique[%temp%]
  295. select /d dir /km >>%fnt (%archive_drive:*-?*-??.%zip_ext)
  296. set count=%@lines[%fnt]
  297. :
  298. :select_file
  299. cls
  300. cdd %toupdate_drive:\
  301. set num=-1
  302.  
  303. :operate
  304. :: This procedure was written with the help of Sam Wilson
  305. :: (SAM.WILSON@emerald.com), 9 Jan 1994, to whom I am deeply
  306. :: grateful. The procedure replaces a previous one, with @select,
  307. :: which allowed file selection only one by one.
  308. ::
  309. set num=%@eval[%num+1]
  310. set fn=%@line[%fnt,%num]
  311. if .%fn==.**EOF** goto end_x
  312. set fn=%archive_drive:%@substr[%fn,0,15]
  313. cls
  314. scrput 1 0 bla on whi Extracting now NEW files from %fn to Drive %toupdate_drive:
  315. rem  (change colors ['bla on whi'] to suit your preference)
  316. screen 2 0
  317. if %@index[%@descript[%fn],Extracted] ge 0 gosub continue?
  318. if "%zip_pgm"=="zip"   set unz=unzip -d -uo %fn %exclude `>&>`nul
  319. if "%zip_pgm"=="pkzip" set unz=pkunzip -d -n %exclude %fn `>&>`nul
  320. if "%zip_pgm"=="uc"    set unz=uc es /f %fn %exclude ##\ `>&>`nul
  321.  
  322. :do_extract
  323. %unz
  324. gosub success_x
  325. goto operate
  326.  
  327. :failure
  328. echo.
  329. echo  No backup files found on drive %archive_drive:
  330. endlocal
  331. quit
  332.  
  333. :end_x
  334. del /q %fnt
  335. if exist %excls_file del /q %excls_file
  336. endlocal
  337. cls
  338. quit
  339. :===========End of the extraction part==================
  340.  
  341.  
  342. :==================SUB-ROUTINES=========================
  343.  
  344. ::(1)----sub-routines for the archiving part------------
  345. :legenda
  346. screen 17 0
  347. text
  348.     Y == extant list will immediately be used for archiving
  349.     N == a new list of files will be generated
  350.     V == the extant list will be viewed, then you can make decision
  351.     E == the list will be called by an editor
  352.     S == the list will be called to screen, one file after the other
  353.     Q == quit
  354. endtext
  355. drawbox 16 0 23 73 1 whi on bla
  356. return
  357. :-------------------------------------------------------
  358. :check_drive
  359. iff %@ready[%dr:] eq 0 then
  360.    echo Insert diskette to Drive %@upper[%dr:], and
  361.    pause
  362.    endiff
  363. if exist %@search[upname.btm] call upname
  364. :: ("upname.btm" checks if your updates disk has got a "name")
  365. return
  366. :------------------------------------------------------
  367. :success
  368. if .%zip_pgm == .zip .or. .%zip_pgm == .pkzip goto _zip
  369. if .%zip_pgm == .uc goto _uc
  370.  
  371. :_uc
  372. iff errorlevel ge 0 then
  373.     if .%state==.old (set brand=upd^gosub brand)
  374.     set ech=echo Backup archive updated on drive %@upper[%dr:]
  375.     return
  376. else
  377.     set ech=
  378.     goto end
  379.  endiff
  380.  
  381. :_zip
  382. rem     Checking results of archiving (with pkzip)
  383.  iff errorlevel eq 12 then
  384.     set ech=Echo (No new or updated files have been created)
  385.  elseiff errorlevel eq 4 then
  386.     cls
  387.     set ech=screen 1 2 (No memory for ZIP to create updates archive)
  388.     goto end
  389.  elseiff errorlevel ge 4 .and. errorlevel le 11 then
  390.     set ech=Echo (Backup archive could not be created / updated)
  391.     goto end
  392.  elseiff errorlevel ge 20 then
  393.     set ech=Echo (Backup archive could not be created / updated)
  394.     goto end
  395.  else
  396.     if .%state==.old (set brand=upd^gosub brand)
  397.     set ech=echo Backup archive updated on drive %@upper[%dr:]
  398.  endiff
  399. return
  400. :-----------------------------------------------------------
  401. :--------sub-sub-routine for marking a file-----------------
  402. : This sub-routine is designed to handle marking files. To save space,
  403. : it handles both "Updated..", and "Extracted" descriptions. This can
  404. : be implemented if the different formulas are first saved on variables.
  405. :brand
  406. iff .%brand==.upd then
  407.   set mark1=Updated
  408.   set mark2=Updated from:
  409.   set mark3=Extracted
  410. elseiff .%brand==.ext then
  411.   set mark1=Extracted
  412.   set mark2=Extracted to:
  413.   set mark3=Updated
  414. endiff
  415.  
  416. set dscr=%@descript[%fn]
  417. if "%dscr"=="" goto 1st_desc
  418. iff %@word[0,%dscr] eq %mark3 .or. "%brand" eq "upd" then
  419.   set %dscr=
  420.   goto 1st_desc
  421. endiff
  422.  
  423. iff %@word[0,%dscr] eq %mark1 then
  424. goto add_compu
  425. endiff
  426.  
  427. :add_compu
  428. if .%compuname==. (describe %fn "%dscr; %mark1; "^return)
  429. describe %fn "%dscr %compuname; "
  430. return
  431.  
  432. :1st_desc
  433. iff .%compuname==. then
  434.     describe %fn "%mark1; "
  435.     return
  436. else
  437.     describe %fn "%mark2 %compuname; "
  438.     return
  439. endiff
  440. :----subroutine for checking if archive be updated----
  441. :void
  442. iff %@lines[%rsp] lt 0 .or. %@lines[%rsp] le 0 .and. %@len[%@line[%rsp,0]] lt 1 then
  443. set ech=scrput %@eval[%_row+1] 2 bri whi on bla No files were found /selected to back up!
  444. echo.
  445. del /q %rsp
  446. goto end
  447.   else
  448.   return
  449. endiff
  450.  
  451. ::(2)-----------SUB-ROUTINES FOR THE EXTRACTION PART-----
  452. :success_x
  453. iff "%zip_pgm"=="zip" then
  454. :: (There is a problem with ZIP errorlevel; it does not work)
  455.   set checkerror=iff errorlevel gt 0 .and. errorlevel lt 9 then
  456. elseiff "%zip_pgm"=="pkzip" then
  457.   set checkerror=iff errorlevel gt 10 .and. errorlevel lt 12 then
  458. elseiff "%zip_pgm"=="uc" then
  459.   set checkerror=iff errorlevel lt 0 then
  460. endiff
  461.  
  462.   %checkerror
  463.     echo (No NEW files found for extracting in %fn)
  464.     if %count ge 0 (echo Press any key to continue...^pause>nul)
  465.   else
  466.     :ok_x
  467.   echo All NEW files from %fn extracted to %toupdate_drive:
  468.   set brand=ext
  469.   gosub brand
  470.   endiff
  471. return
  472.  
  473. :continue?
  474. iff %@index[%@descript[%fn],%compuname] ge 0 then
  475. goto force?
  476. else
  477. return
  478. endiff
  479.  
  480. :force?
  481. set rsp=Q
  482. inkey /W4 /K"EDQ" File %@upper[%fn] already extracted. E(xtract), D(elete), Q(uit)? %%rsp
  483. if %rsp == E return
  484. if %rsp == Q (echo Forced extraction canceled^goto operate)
  485. if %rsp == D (del /q %fn^echo File %fn deleted^goto operate)
  486.  
  487. :-----------SUBROUTINES FOR DRIVE CHECKING-----------
  488. ::(1)-------archiving part---------------
  489. :check_args
  490. iff %@eval[%#] eq 0 then
  491. gosub defaults
  492. goto start_program
  493.   elseiff %@eval[%#] eq 1 then
  494.   goto check_1
  495.   elseiff %@eval[%#] eq 2 then
  496.   goto check_2
  497.   elseiff %@eval[%#] ge 3 then
  498.   goto check_3
  499. endiff
  500.  
  501. :ask_drives
  502. inkey Search Drive (letter only)? %%search_drive
  503. inkey Archive Drive (letter only)? %%archive_drive
  504. return
  505.  
  506. :check_1
  507. iff not %@index[%1,:] ge 0 then
  508.  gosub defaults
  509. goto start_program
  510.    else
  511.  echo Only one drive specified!
  512.  gosub ask_drives
  513.  shift
  514. goto start_program
  515. endiff
  516.  
  517. :check_2
  518. iff %@index[%1,:] ge 0 .xor. %@index[%2,:] ge 0 then
  519.  gosub ask_drives
  520. shift 1
  521. goto start_program
  522.    else
  523.  set search_drive=%1
  524.  set archive_drive=%2
  525.  shift 2
  526.  goto start_program
  527. endiff
  528.  
  529. :check_3
  530. set search_drive=%1
  531. set archive_drive=%2
  532. shift 2
  533.  
  534. :start_program
  535. :: (Eliminate "/zip" or "/pkz" from the arguments passed on)
  536. iff %@index[%1,/pkz] ge 0 .or. %@index[%1,/zip] ge 0 .or. %@index[%1,/uc] ge 0 then
  537. shift 1
  538. endiff
  539.  
  540. iff %@index[%1,/x] ge 0 then
  541. shift 1000
  542. endiff
  543.  
  544. :drives  :: (eliminate colon from drive names)
  545. set dr=%archive_drive
  546.     iff %@index[%dr,:] eq 1 then
  547.         set dr=%@substr[%dr,1,-1]
  548.     endiff
  549.     iff %@index[%search_drive,:] eq 1 then
  550.         set search_drive=%@substr[%search_drive,1,-1]
  551.     endiff
  552.  
  553. return
  554. rem (return to the beginning of updating)
  555.  
  556. ::(2)-------extraction part---------------
  557. :check_args_x
  558. shift
  559. iff %@eval[%#] eq 0 then
  560. gosub defaults_x
  561. goto start_ext
  562.   elseiff %@eval[%#] eq 1 then
  563.   goto check_1_x
  564.   elseiff %@eval[%#] ge 2 then
  565.   goto check_2_x
  566. endiff
  567.  
  568. :ask_drives_x
  569. inkey Drive to extract to (letter only)? %%toupdate_drive
  570. inkey Drive to extract from (letter only)? %%archive_drive
  571. return
  572.  
  573. :check_1_x
  574. iff not %@index[%1,:] ge 0 then
  575.  gosub defaults_x
  576. goto start_ext
  577.    else
  578.  echo Only one drive specified!
  579.  gosub ask_drives_x
  580.  shift
  581. goto start_ext
  582. endiff
  583.  
  584. :check_2_x
  585. iff %@index[%1,:] ge 0 .xor. %@index[%2,:] ge 0 then
  586.  gosub ask_drives_x
  587. shift 1
  588. goto start_ext
  589.    else
  590.  set toupdate_drive=%@substr[%1,1,-1]
  591.  set archive_drive=%@substr[%2,1,-1]
  592.  shift 2
  593.  goto start_ext
  594. endiff
  595.  
  596. :start_ext
  597. :: (Eliminate "/zip" or "/pkz" or "/uc" from the arguments passed on)
  598. iff %@index[%1,/pkz] ge 0 .or. %@index[%1,/zip] ge 0 .or. %@index[%1,/uc] ge 0 then
  599. shift 1
  600. endiff
  601.  
  602. :drives_x  :: (eliminate colon from drive names)
  603.  iff %@index[%archive_drive,:] eq 1 then
  604.   set archive_drive=%@substr[%archive_drive,1,-1]
  605.  elseiff %@index[%toupdate_drive,:] eq 1 then
  606.   set toupdate_drive=%@substr[%toupdate_drive,1,-1]
  607.  endiff
  608.  
  609. return
  610. rem (go back to the beginning of extraction)
  611. ::===========================================
  612. :----sub-sub-routines to 'checking drives'---
  613. ::===========================================
  614. :: (setting default drives for compression and extraction.
  615. :: These defaults can be overridden via BKUP.INI, or from
  616. :: the command line.)
  617. :defaults
  618. if .%search_drive ==. set search_drive=%_boot
  619. if .%archive_drive==. set archive_drive=B:
  620. return
  621.  
  622. :defaults_x
  623. if .%toupdate_drive==. set toupdate_drive=%_boot
  624. if .%archive_drive ==. set archive_drive=B
  625. return
  626. :=============END of SUB-ROUTINES============
  627.  
  628. ::-------------------------------------------::
  629. ::   EVALUATION OF PARAMETERS AND OPTIONS    ::
  630. ::-------------------------------------------::
  631. :bk-prams
  632.  
  633. :check_batches  :: (look for batch files used by BKUP)
  634. iff not exist %@search[bk-hlp.btm] then
  635.    beep^echo BK-HLP.BTM not found. It is needed for BKUP to work
  636.    echo (See BKUP.LST for details.)
  637.    cancel
  638. elseiff not exist %@search[settemp.btm] then
  639.    beep^echo SETTEMP.BTM not found. It is needed for BKUP to work
  640.    echo (See BKUP.LST for details.)
  641.    cancel
  642. elseiff not exist %@search[upname.btm] then
  643.    beep^echo UPNAME.BTM not found. It is needed for BKUP to work
  644.    echo (See BKUP.LST for details.)
  645.    cancel
  646. endiff
  647.  
  648. call settemp
  649. :: ("settemp.btm" determines which drive will be defined as "temp",
  650. :: if it is not yet defined by user [preferably in AUTOEXEC.BAT file].)
  651.  
  652. :load_ini
  653. :: (loads configuration file)
  654. if exist %@search[bkup.ini] set /r %@search[bkup.ini]
  655.  
  656. :set_params
  657. ::
  658. :(1)zip_pgm
  659. :: (compressions pgm: Free ZIP/UNZIP, Katz's PKZIP/PKUNZIP, or UC2)
  660. :: (/pkz, /zip, or /uc on the command line will select PKZIP, ZIP, or UC2
  661. ::  respectively. Default [below, :defaultzip] is PKZIP.)
  662.        iff %@index[%args,/pkz] ge 0 then
  663.           set zip_pgm=pkzip
  664.           set zip_ext=zip
  665.        elseiff %@index[%args,/zip] ge 0 then
  666.           set zip_pgm=zip
  667.           set zip_ext=zip
  668.        elseiff %@index[%args,/uc] ge 0 then
  669.           set zip_pgm=uc
  670.           set zip_ext=uc2
  671.        elseiff .%zip_pgm==. then
  672.      :defaultzip   :: (Modify default below if desired)
  673.           set zip_pgm=pkzip
  674.           set zip_ext=zip
  675.       endiff
  676.  
  677. :set_prams
  678.    iff "%zip_pgm"=="zip" then
  679.           iff %@eval[%@dosmem[k]] lt 600 then
  680.           beep
  681.           echo No memory for compression with %@upper[%zip_pgm]
  682.           cancel
  683.           endiff
  684.        set zip_ext=zip
  685.        set pkz=zip -uk -9 -b %temp
  686.    elseiff "%zip_pgm"=="pkzip" then
  687.        set zip_ext=zip
  688.        set pkz=pkzip -b%temp -P -u -ex
  689.    elseiff "%zip_pgm"=="uc" then
  690.        set zip_ext=uc2
  691.        set pkz=uc a -## -f
  692.           iff %@eval[%@dosmem[k]] lt 400 then
  693.           ::us.exe
  694.           ::set pkz=uuc a -## -f
  695.           beep
  696.           echo No memory for compression with %@upper[%zip_pgm]
  697.           cancel
  698.           endiff
  699.    endiff
  700.  
  701. :(2)exclude_list
  702. :: (files not to be included in update archives or not to be extracted
  703. :: from the archive. The filenames are read from BKUP.INI, but this can
  704. :: be  overridden by the /x switch on the command line.
  705. ::
  706.   iff %@index[%args,/x] ge 0 then
  707.         set exc=%@eval[%@index[%args,/x]+2]
  708.         set excludes=%@substr[%args,%exc]
  709.         goto an_excludes
  710.   elseiff not "%excludes"=="" then
  711.         goto an_excludes
  712.      endiff
  713.  
  714. :an_excludes
  715.  set lenexc=%@len[%excludes]
  716.    iff "%zip_pgm"=="zip" then
  717.    set exclude=-x
  718.    goto parse_excludes
  719.    elseiff "%zip_pgm"=="pkzip" .or. "%zip_pgm"=="uc" then
  720.    set exclude=
  721.    goto parse_excludes
  722. endiff
  723.  
  724. :parse_excludes
  725. if %_4ver lt 5 goto 4ver_loop
  726. set num=0
  727. do forever
  728.   set wo=%@word[%num,%excludes]
  729.   if "%wo"=="" leave
  730.   set num=%@eval[%num+1]
  731.   gosub cmpr_pgm
  732. enddo
  733. goto check_type
  734.  
  735. :4ver_loop
  736. call bk-4ver.btm parse_exclude4
  737.  
  738. :check_type
  739. if %lenexc ge 54 set excl_file=on
  740. if .%excl_file==.on gosub mark_excl
  741.  
  742. :(3)editor
  743. :: (if not defined in ini file)
  744. if not "%editor"=="" set edt=%editor
  745. if "%edt"=="" INPUT No editor defined. Type your preferred editor's name: %%edt
  746.  
  747. return
  748. :: (return to main program)
  749.  
  750. ::===========SUB-ROUTINES FOR PARAMETERS===========
  751. ::---sub-routine for checking computer "name"------
  752. :compuname
  753. :: (temporarily naming your computer if not named yet)
  754.    if "%@label[%search_drive]"=="" goto give_name
  755.    set compuname=%@label[%search_drive]
  756.    return
  757.    :give_name
  758.    cls
  759.    screen 2 2 Your BKUP.INI file is missing and your search drive
  760.    screen 3 2 (currently %search_drive%:) has no label.
  761.    screen 4 2
  762.    inkey /K"YN" Give it a (temporary) name now? (Y/N) %%rep
  763.         iff %rep == Y then goto name2
  764.     elseiff %rep == N then return
  765.     endiff
  766.  
  767.     :name2
  768.      input Type the name you wish to call your computer: %%compuname
  769.  
  770.      inkey /K"YN" Read how to make it permanent? (Y/N) %%rep
  771.            iff %rep == Y then set compu=on^call bk-hlp name_text^return
  772.        elseiff %rep == N then return
  773.      endiff
  774. ::----------end of "name" sub-routine---------
  775.  
  776. ::----------sub-routine for recomposing-------
  777. :cmpr_pgm
  778. ::-----sub-routine to recompose the components
  779. ::     of the exclusion line according to the syntax
  780. ::     of each compression program supported.
  781.   iff %lenexc ge 54 .and. .%zip_pgm==.pkzip then
  782.   gosub excl_file
  783.   elseiff %lenexc ge 54 .and. .%zip_pgm==.zip then
  784.   echo You must reduce your exclude line by %@eval[%lenexc-53] characters
  785.   echo (It is currently %lenexc)
  786.   cancel
  787.   endiff
  788.  if .%excl_file==.on return
  789. iff .%zip_pgm==.pkzip then
  790.  set exclude=%exclude -x%wo
  791.  return
  792. elseiff .%zip_pgm==.zip then
  793.  set exclude=%exclude \%wo
  794.  return
  795. elseiff .%zip_pgm==.uc then
  796.  set exclude=%exclude !%wo
  797.  return
  798. endiff
  799.  
  800. :: Note (April 29, 1994): exclude list does not work yet
  801. :: for script files in UC2; therefore make sure you do not
  802. :: leave undesired filenames in the edited list of updated files.
  803.  
  804. :excl_file
  805. echo %wo >> %excls_file
  806. set excl_file=on
  807. return
  808.  
  809. ::----sub-routine for excl_file----
  810. :mark_excl
  811. iff .%zip_pgm==.pkzip then
  812.  set exclude=-x@%excls_file
  813.  return
  814. elseiff .%zip_pgm==.zip then
  815.  :: no solution for longer exclude line in ZIP at the moment
  816.  ::echo %exclude > %excls_file
  817.  ::set exclude=-@ %excls_file
  818.  return
  819. elseiff .%zip_pgm==.uc then
  820.  echo %exclude > %excls_file
  821.  set exclude=@%excls_file
  822.  return
  823. endiff
  824.